#include <iostream>


#include "BlockQueue.hpp"


void* routine_productor(void* arg)
{
    block_queue<int>* bq = (block_queue<int>*)arg;
    int task = 0;
    while(true)
    {
        sleep(1);
        //生产商品
        bq->push(task++);
    }

}

void* routine_consumer(void* arg)
{
    block_queue<int>* bq = (block_queue<int>*)arg;
    while(true)
    {
        sleep(1);
        //消费商品
        bq->pop();
    }

}

int main()
{
    block_queue<int>* bq = new block_queue<int>();

    pthread_t p;
    pthread_t c;

    pthread_create(&p, nullptr, routine_productor, bq);
    pthread_create(&c, nullptr, routine_consumer, bq);


    pthread_join(p, nullptr);
    pthread_join(c, nullptr);


    return 0;
}